﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HtFileSync
{

    public class FileDbCfg
    {
        public static SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
        {
            DbType = DbType.Sqlite,//数据库类型
            ConnectionString = "DataSource="+Program.dbcon,//连接符字串
            InitKeyType = InitKeyType.Attribute,
            IsAutoCloseConnection = true, //不设成true要手动close
            MoreSettings = new ConnMoreSettings
            {
                SqliteCodeFirstEnableDefaultValue = true //启用默认值
                // IsCorrectErrorSqlParameterName = true, // 参数名有空格特殊符号使用兼容模式，对性能会有影响，能局部修改配置就局部，尽量不要全局使用
            }
      
        });


        public static void CreateDatabase()
        {
            //建库：如果不存在创建数据库存在不会重复创建
            db.DbMaintenance.CreateDatabase();
            //建表
            if (!db.DbMaintenance.IsAnyTable("FileSyncdb"))db.CodeFirst.SetStringDefaultLength(200).InitTables(typeof(FileSyncdb));
        }

    }



    public class FileSyncdb
    {
        [SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
        public int Id { get; set; }
        public DateTime CompletionTime { get; set; }
        public string FileName { get; set; }
        public long FileSize { get; set; }
        [SugarColumn(IsNullable = true)]
        public string? FileCRC { get; set; }
        public DateTime FileCreateTime { get; set; }
        public DateTime FileModifyTime { get; set; }
        public bool IsComplete { get; set; }
    }


    public class AppSet
    {
        public string? TextBox1 { get; set; }
        public string? TextBox2 { get; set; }
        public string? WorkMode { get; set; }
        public bool OnlyExtensions { get; set; }
        public string? OnlyExtensionsText { get; set; }
        public bool IncludeSubfolders { get; set; }
        public bool ZipFileCheck { get; set; }
        public string? ZipFormat { get; set; }
        public bool DeleteOldFileCheck { get; set; }
        public string? DelOldDays { get; set; }
        public bool ExecuteRadioButton { get; set; }
        public bool IntervalRadioButton { get; set; }
        public bool EverydayRadioButton { get; set; }
        public string? TextBoxDay { get; set; }
        public string? TextBoxHour { get; set; }
        public string? TextBoxMinute { get; set; }
        public string? TextBoxSecond { get; set; }
        public bool EveryDayCheck1 { get; set; }
        public bool EveryDayCheck2 { get; set; }
        public bool EveryDayCheck3 { get; set; }
        public bool EveryDayCheck4 { get; set; }
        public bool EveryDayCheck5 { get; set; }
        public DateTime EveryDayTime1 { get; set; }
        public DateTime EveryDayTime2 { get; set; }
        public DateTime EveryDayTime3 { get; set; }
        public DateTime EveryDayTime4 { get; set; }
        public DateTime EveryDayTime5 { get; set; }

    }



}
